
import { readBinary } from '@linksaas-git/widget';
import { useEffect, useState } from 'react';
import { ReactReader } from 'react-reader';

function App() {
  const [epubData, setEpubData] = useState<ArrayBuffer | null>(null);
  const [location, setLocation] = useState<string | number>(0);

  useEffect(() => {
    readBinary().then(data => {
      setEpubData(data.buffer);
    })
  }, []);

  return (
    <div style={{ height: '100vh' }}>
      {epubData != null && (
        <ReactReader url={epubData}
          epubOptions={{
            allowScriptedContent: true,
          }}
          location={location}
          locationChanged={(epubcfi: string) => setLocation(epubcfi)} />
      )}

    </div>
  )
}

export default App
